/**
 * Used only in C-API based Architecture.
 * MIT License
 *
 * Copyright (C) 2023 Huawei Device Co., Ltd.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#ifndef FAST_IMAGE_NODE_H
#define FAST_IMAGE_NODE_H

#include <react/renderer/imagemanager/primitives.h>
#include "RNOH/arkui/ArkUINode.h"

namespace rnoh {

class FastImageNodeDelegate {
public:
    virtual ~FastImageNodeDelegate() = default;
    virtual void onComplete(float width, float height){};
    virtual void onError(int32_t errorCode){};
    virtual void onProgress(uint32_t loaded, uint32_t total){};
};

class FastImageNode : public ArkUINode {
protected:
    ArkUI_NodeHandle m_childArkUINodeHandle;
    FastImageNodeDelegate* m_fastImageNodeDelegate;

public:
    FastImageNode();
    ~FastImageNode();
    FastImageNode& setSources(std::string const& uri, std::string prefix = "");
    FastImageNode& setResizeMode(facebook::react::ImageResizeMode const& mode);
    FastImageNode& setTintColor(facebook::react::SharedColor const& sharedColor);
    FastImageNode& setBlur(facebook::react::Float blur);
    FastImageNode& setObjectRepeat(
        facebook::react::ImageResizeMode const& resizeMode);
    FastImageNode& setCapInsets(facebook::react::EdgeInsets const& capInsets, float dpi);

    FastImageNode& setInterpolation(int32_t interpolation);
    FastImageNode& setDraggable(bool draggable);
    FastImageNode& setFocusable(bool focusable);
    FastImageNode& setResizeMethod(std::string const& resizeMethod);
    FastImageNode& setAlt(std::string const& uri, std::string prefix = "");
    FastImageNode& setFadeDuration(int32_t duration);

    FastImageNode& resetFocusable();
    FastImageNode& resetResizeMethod();
    FastImageNode& setAutoResize(bool autoResize);
    FastImageNode& resetSources();

    void onNodeEvent(ArkUI_NodeEventType eventType, EventArgs& eventArgs) override;
    void setNodeDelegate(FastImageNodeDelegate* fastImageNodeDelegate);
};
} // namespace rnoh

#endif // FAST_IMAGE_NODE_H
